package  com.sat.common.widget.commom

import android.os.Bundle
import androidx.annotation.LayoutRes

/**
 * 通用DialogFragment抽象类
 *
 * @author DavenXie
 * Created by Daven on 2018/7/5.
 */
class CommonDialogFragment : BaseDialogFragment() {
    private var convertListener: ViewConvertListener? = null
    override fun intLayoutId(): Int {
        return layoutId
    }



    override fun convertView(
        holder: ViewHolderHelper?,
        dialog: BaseDialogFragment?
    ) {
        if (convertListener != null) {
            convertListener!!.convertView(holder, dialog)
        }
    }

     fun setLayoutId(@LayoutRes layoutId: Int): CommonDialogFragment {
        this.layoutId = layoutId
        return this
    }

    fun setConvertListener(convertListener: ViewConvertListener?): CommonDialogFragment {
        this.convertListener = convertListener
        return this
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

    }

    /**
     * 保存接口
     *
     * @param outState
     */
    override fun onSaveInstanceState(outState: Bundle) {
        super.onSaveInstanceState(outState)
    }

    override fun onDestroyView() {
        super.onDestroyView()
        convertListener = null
    }

    companion object {
        fun newInstance(): CommonDialogFragment {
            return CommonDialogFragment()
        }
    }
}